<template>
    <div class="tab-contral">
        <div 
         v-for="(item,index) in tabs" :key="index"
         class="tab-contral-item"
         :class="{isactive:index===currentIndex}"
         @click="addCurrentIndex(index)"
       >
            <span>{{item}}</span>
        </div>
    </div>
</template>

<script>
export default {
    data () {
        return {
            currentIndex:0
        }
    },
    props:{
        tabs:{
            type:Array
        }
    },
    methods: {
        addCurrentIndex(index){
            this.currentIndex=index
            //将当前点击得index传入home中
            this.$emit('getTabIndex', index)
        }
    }
    
};
</script>

<style lang="less" scoped>
.tab-contral{
    display: flex;
    text-align: center;
    background-color: #fff;
    height: 40px;
    line-height: 40px;
    .tab-contral-item{
        flex: 1;
    }
}
.isactive span{
    border-bottom: 2px solid red;
    padding: 10px;

}

</style>

